<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	</head>
	<body>
		<script language="javascript">
			function userNameChangeBox()
			{
				document.getElementById('div1').style.display='none';
				document.getElementById('div2').style.display='';
				document.getElementById('userName').focus();
			}
			function userNameRestoreBox()
			{
				if(document.getElementById('userName').value=='')
				{
  					document.getElementById('div1').style.display='';
  					document.getElementById('div2').style.display='none';
				}
			}
			function passwordChangeBox()
 			{
    			document.getElementById('div3').style.display='none';
    			document.getElementById('div4').style.display='';
    			document.getElementById('password').focus();
 			}
 			function passwordRestoreBox()
 			{
    			if(document.getElementById('password').value=='')
    			{
      				document.getElementById('div3').style.display='';
      				document.getElementById('div4').style.display='none';
    			}
 			}
			</script>
       		<div>
       		<%
    			if ( session.getAttribute("currentSessionUser") == null && session.getAttribute("LoginError") != "true" ) {
        	%>
        	<form method="get" action="login.do" >
					<div id="div1">
						<input name="userName_temp" type="text" value="username" size="20" maxlength="20" onfocus="userNameChangeBox()" />
					</div>
					<div id="div2" style="display:none">
						<input name="userName" id="userName" type="text" value="" size="20" maxlength="20" onBlur="userNameRestoreBox()" />
					</div>
					<div id="div3">
						<input name="pass_temp" type="text" value="password" size="20" maxlength="20" onfocus="passwordChangeBox()" />
					</div>
					<div id="div4" style="display:none">
						<input name="password" id="password" type="password" value="" size="20" maxlength="20" onBlur="passwordRestoreBox()" />
					</div>
  				<input type="submit" name="Login" value="Login">
  			</form>
        	<%
    		} else if (session.getAttribute("LoginError") == "true") {
        	%>
        	<form method="get" action="logRetry.do" >
        		Sorry, wrong username or password.
        		<br>
        		<input type="submit" name="Logout" value="Retry">
        	</form>
			<%
    		} else {
        	%>
        	<form method="get" action="logout.do" >
        		Welcome, 
        		<%= session.getAttribute("currentSessionUser")%>.
        		<br>
        		<input type="submit" name="Logout" value="Logout">
        	</form>
        	<%
    		}
			%>
		</div>
	</body>
</html>